n = int(input())
a = list(map(int, input().split()))
r = 0
for i in range(29, -1, -1):
c = 0
for j in a:
if (j >> i) & 1:
c += 1
r = j
if c == 1:
break
a.remove(r)
print(r, ' '.join(map(str, a)))
num_inp=lambda: int(input())
arr_inp=lambda: list(map(int,input().split()))
sp_inp=lambda: map(int,input().split())
str_inp=lambda:input()
#include <bits/stdc++.h>
#define fs first
#define se second
#define pb push_back
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
#define all(x) (x).begin(), (x).end()
#define mk make_pair
#define endl '\n'
// #define double long double
#define int long long
using namespace std;
typedef long long LL;
const int N = 2e5 + 10, mod = 1e9 + 7, M = 2 * N;
const double eps = 1e-5;
const LL INF = 1e15;
typedef pair<int, int> PII;
int g[N];
vector<int> v[50];
signed main()
{
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int n;
cin >> n;
for (int i = 1; i <= n; i++)
{
cin >> g[i];
for (int j = 31; j >= 0; j--)
{
if ((g[i] >> j) & 1)
{
v[j].pb(i);
}
}
}
int flag=0;
for(int i=30;i>=0;i--)
{
if(v[i].size()==1)
{
cout<<g[v[i][0]]<<' ';
flag=v[i][0];
break;
}
}
if(!flag)
{
for(int i=1;i<=n;i++) cout<<g[i]<<' ';
}
else
{
for(int i=1;i<=n;i++)
{
if(i!=flag) cout<<g[i]<<' ';
}
}
return 0;
}
1367B - Even Array | 136A - Presents |
1450A - Avoid Trygub | 327A - Flipping Game |
411A - Password Check | 1520C - Not Adjacent Matrix |
1538B - Friends and Candies | 580A - Kefa and First Steps |
1038B - Non-Coprime Partition | 43A - Football |
50A - Domino piling | 479A - Expression |
1480A - Yet Another String Game | 1216C - White Sheet |
1648A - Weird Sum | 427A - Police Recruits |
535A - Tavas and Nafas | 581A - Vasya the Hipster |
1537B - Bad Boy | 1406B - Maximum Product |
507B - Amr and Pins | 379A - New Year Candles |
1154A - Restoring Three Numbers | 750A - New Year and Hurry |
705A - Hulk | 492B - Vanya and Lanterns |
1374C - Move Brackets | 1476A - K-divisible Sum |
1333A - Little Artem | 432D - Prefixes and Suffixes |